package com.i2863.watchdog.sms;

/**
 * User: xuweiwei
 * Date: 2017/4/17
 */
public enum SmsCodeType {
    PARAM_EMPTY(-1, "参数为空。信息、电话号码等有空指针，登陆失败"),
    PHONE_ILLEGAL(-12, "有异常电话号码"),
    OVER_LIMIT(-14, "实际号码个数超过1000"),
    SERVICE_ERROR(-999, "服务器内部错误"),
    LOGIN_FAIL(-10001, "用户登陆不成功(帐号不存在/停用/密码错误)"),
    OVER_MONEY(-10003, "用户余额不足"),
    OVER_LENGTH(-10011, "信息内容超长"),
    PERMISSION_DENIED(-10029, "此用户没有权限从此通道发送信息(用户没有绑定该性质的通道，比如：用户发了小灵通的号码)"),
    SEND_ERROR(-10030, "不能发送移动号码"),
    ERROR_SEGMENT(-10031, "手机号码(段)非法"),
    IP_ERROR(-10057, "IP受限"),
    OVER_CONNECT(-10056, "连接数超限");

    /**
     * 错误编码
     */
    private int code;
    /**
     * 错误说明
     */
    private String msg;


    SmsCodeType(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static SmsCodeType valueOf(int code) {
        for (SmsCodeType type : SmsCodeType.values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的code:" + code);
    }

}
